In the field of computer systems, a program may allocate memory for objects from a free memory area called a heap. Memory is allocated to, and freed from, the heap. Eventually, when the objects are no longer being referenced by the program, the memory allocated for the created objects is reclaimed through a garbage collection process. Garbage collection may refer to a process of identifying unused areas of main memory storage. The garbage collection process clears the objects from memory, and the once allocated memory is again available for use.
Modern programs may dynamically generate objects that are stored on the heap. Although different uses of the term may exist, the discussion that follows will use heap to refer to shared memory managed by automatic garbage collection. The garbage collector has control of and/or direct access and/or knowledge of the addresses, classes, roots, and other such detailed information about all live objects created in the system. After an object is no longer needed, it may be desirable to reclaim the memory allocated to the object to prevent the system from running out of memory as more temporary objects fill the heap. Garbage collectors operate by reclaiming space that is no longer “reachable.”
In some systems, which are usually known as “object oriented,” objects may have associated methods, which are routines that can be invoked by reference to the object. An object may belong to a class, which is an organizational entity that may contain method code or other information shared by all objects belonging to that class. In the discussion that follows, though, the term object will not be limited to such structures; it will additionally include structures with which methods and classes are not associated.